<template>
	<view class="recordList">
		<view class="recorditem" @click="goReceive(item)" v-for="(item, index) in dataList" :key="index">
			<image class="ri-img" :src="item.logo"></image>
			<view class="ri-right">
				<view class="u-line-2">{{ item.name }}</view>
				<view class="right-bottom">
					<text class="r-title" v-if="item.receive == 1">你发送{{ item.num }}个红包，已被领取{{ item.send_num }}个红包</text>
					<text class="r-title" v-else>你已领{{ item.num }}个红包</text>
				</view>
				<view class="r-time">{{ item.date_creation | formatTime() }}</view>
			</view>
		</view>
		<sww-load-more :params="dataListParams"></sww-load-more>
	</view>
</template>

<script>
import { pagingMixin } from '@/mixins/pagingMixin.js';
import { formatDate } from '@/utils/moment/index.js';
export default {
	mixins: [pagingMixin],
	data() {
		return {};
	},
	filters: {
		formatTime(val) {
			return formatDate(val, 'YYYY-MM-DD HH:mm:ss');
		}
	},
	mounted() {
		this.pageInit();
	},
	methods: {
		pageInit() {
			this._init_data('GetRedEnvelopesRecordList', {}, { showLoading: true });
		},
		$onReachBottom() {
			this._load_data();
		},
		selectIndex(index) {
			this.currentIndex = index;
		},
		// 查看红包记录
		goReceive(item) {
			let recordeId = item.fk_record_id;
			if (item.receive == 1) { // 发送
				recordeId = item.pk_id;
			}
			if(recordeId > 0){
				this.$linkTo(`/package/redEnvelopes/receive?id=${recordeId}&no_share=1`);
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.recordList {
	margin-top: 20rpx;
	.recorditem {
		display: flex;
		align-items: center;
		padding: 20rpx;
		background-color: #fff;
		.ri-img {
			width: 120rpx;
			height: 120rpx;
			margin-right: 20rpx;
		}
		.ri-right {
			display: flex;
			flex-direction: column;
			width: 80%;
			.right-bottom {
				padding-top: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.r-title {
					font-size: 22rpx;
					color: var(--color);
				}
			}
			.r-time {
				text-align: right;
				font-size: 22rpx;
				color: #999;
				margin-top: 10rpx;
			}
		}
	}
}
</style>
